package com.usian.fallback;

import com.usian.feign.UserFeign;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import pojo.User;


@Component
public class UserFeignFallback implements FallbackFactory<UserFeign> {

    private Logger log = LoggerFactory.getLogger(UserFeignFallback.class);

    @Override
    public UserFeign create(Throwable throwable) {
        return new UserFeign() {

            public User getUserById(Integer id, String nam) {
                log.error("通过id查询用户异常:{}", id, throwable);
                return new User(id,"我是托底数据Fallback,王某人&陈琳琳",0);
            }
        };
    }
}